package com.ang.redisson.controller;

import com.ang.redisson.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import java.util.UUID;

/**
 * @description: ${description}
 * @author: ssang
 * @create: 2021/5/10 0010 14:44
 **/
@Controller
@RequestMapping("/test")
public class TestController {

    @Autowired
    ProductService productService;

    /**
     * 测试redisson分布式锁
     * 先在redis中创建一个key为k0001的数据，值为100；模拟productId为k0001的订单，有100个库存
     * 如： k0001:100，订单k0001有100库存
     */
    @RequestMapping("/createOrder")
    @ResponseBody
    public void createOrder(){
        String productId = "k0001";
        productService.createOrder(productId);
    }
}
